package com.smile.stream.group;

import com.smile.stream.StreamUtil;
import com.smile.stream.pojo.Dish;
import com.smile.stream.pojo.Type;

import java.util.List;
import java.util.Map;
import static java.util.stream.Collectors.*;

/**
 * @author LiYuhang
 * @version 0.1
 * @application
 * @Date 2021/10/7 21:50
 */
public class Group4 {
    public static void main(String[] args) {
        Map<Boolean, Map<Type, List<Dish>>> collect = StreamUtil
                .getMenu()
                .parallelStream()

                .collect(partitioningBy(Dish::isVegetarian,groupingBy(Dish::getType)));
        System.out.println("collect = " + collect);
        //collect = {false={FISH=[prawns, salmon], MEAT=[pork, beef, chicken]},
        // true={OTHER=[french fries, rice, season fruit, pizza]}}
    }
}
